package es.cazadoresmadridejos.beans.controller.event;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import es.cazadoresmadridejos.beans.manager.session.UserPreferences;
import es.cazadoresmadridejos.model.Event.EventType;
import es.cazadoresmadridejos.model.Reason;
import es.cazadoresmadridejos.web.util.ListUtil;

@Controller
public class EventProfileController {
	
	@Autowired(required=false) private UserPreferences userPreferences;
	
	@RequestMapping("/eventProfile.html")
	public ModelAndView profile(
			){
		ModelAndView mv = new ModelAndView("eventCreateModify");
		mv.addObject("eventTypes",ListUtil.toString(EventType.values()));
		
		
		Reason reason = userPreferences.getReason();
		mv.addObject("startYear", reason.getStartYear());
		mv.addObject("endYear", reason.getEndYear());
		
		return mv;
	}
}
